package JavaExercise;

import java.util.Scanner;

public class Fibonacci {
    static Scanner sc = new Scanner (System.in);
    static  int n ;
    public static void main(String[] args) {
        System.out.println("你要展示第几项为止的数？");
        n = sc.nextInt();
        int [] fArr ;
        fArr = getFibonacci();
        for (int x: fArr){
            System.out.print(x+" ");
        }
    }

    public  static int [] getFibonacci( ){
        int [] fArr = new int[n];
        if (n>1) {
            fArr[0] = 1;
            fArr[1] = 1;
            for (int i = 2; i < fArr.length; i++) {
                fArr[i] = fArr[i - 1] + fArr[i - 2];
            }
        }
        return fArr;
    }


}
